package com.ding.dailyup.controller;

import cn.hutool.core.util.StrUtil;
import com.ding.dailyup.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ding.dailyup.entity.JsonResult;
import com.ding.dailyup.entity.response.IndexDataResp;
import com.ding.dailyup.service.SystemNoticeService;

import io.swagger.annotations.Api;

@RestController
@RequestMapping("/index")
@Api(tags = "首页数据")
public class IndexController {

	@Autowired
	private SystemNoticeService systemNoticeService;
	@Autowired
	private SysConfigService sysConfigService;

	@GetMapping("/data")
	public JsonResult<IndexDataResp> notice() {
		IndexDataResp indexDataResp = new IndexDataResp();
		indexDataResp.setNoticeContent(systemNoticeService.getSystemNotice());

		String showK = sysConfigService.getValueByDataTypeAndKey("index",
				"showK");
		if (StrUtil.isNotEmpty(showK)) {
			indexDataResp.setK(Boolean.parseBoolean(showK));
		}
		return JsonResult.succResult(indexDataResp);
	}
}
